import React from 'react'
import { $pre } from "../../../../http/http"
import "./goods.less"
import { JumboTabs } from "antd-mobile"
import { withRouter } from 'react-router-dom'


function goods(props) {
    let { goods, n, onchangen } = props
    let nav = ["综合推荐", "销量", "价格"]
    return (
        <div className='goods'>
            <JumboTabs onChange={(key) => onchangen(key)}>
                {
                    nav.map((item, index) => {
                        return (
                            <JumboTabs.Tab title={item} key={index + ""}>
                                {goods.length > 0 ? (
                                    <div>
                                        {goods[n].content.map(i => {
                                            return <div className='card' key={i.id} onClick={() => {
                                                props.history.push("/detail/"+i.id)
                                            }}>
                                                <img src={$pre + i.img} alt="" />
                                                <div className="right">
                                                    <h3>商品名称：{i.goodsname}</h3>
                                                    <p className='price'>价格：{i.price}</p>
                                                    <p className='market_price'>原价：{i.market_price}</p>
                                                </div>
                                            </div>
                                        })}
                                    </div>
                                ) : (<div>暂无数据</div>)}
                            </JumboTabs.Tab>
                        )
                    })
                }
            </JumboTabs>
        </div>
    )
}

export default withRouter(goods)